/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.farent.solutions.plugins.stripes.hyperstripes.core;

import com.farent.solutions.plugins.stripes.hyperstripes.utils.Utils;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;

/**
 *
 * @author farouka
 */
public class RootComponentModel extends DefaultComponentModel implements
        ComponentModel
{

    @Override
    public boolean isChild(ComponentModel child) {
        //accepts any child
        return true;
    }

    @Override
    public String getName() {
        return "pageWrapper";
    }

    @Override
    public void processTag(XMLStreamReader streamReader) {
        String idAttr = null;
        setName(streamReader.getName().getPrefix() + ":" + streamReader.getName().getLocalPart());
        for (int i = 0, n = streamReader.getAttributeCount(); i < n; ++i) {
            Attribute componentAttr = new Attribute();
            QName an = streamReader.getAttributeName(i);
            String av = streamReader.getAttributeValue(i);
            av = av.trim();
            if ( !Utils.assignIfhasOwnProperty( this, an.getLocalPart(), av) ) {
                componentAttr.setName(an.getLocalPart());
                componentAttr.setValue(av);
                addAttribute(componentAttr);
                if (an.getLocalPart().equalsIgnoreCase("id")) {
                    idAttr = av;
                }
            }
        }
    }

}
